package cn.jiyun.ai.common;

import cn.jiyun.ai.common.enums.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer code;

    private String msg;

    private Object data;

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static Result ok(Object data){
    	return new Result(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg(),data);
    }

    public static Result ok(){
        return new Result(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg());
    }

    public static Result ok(ResultCodeEnum resultCodeEnum){
        return new Result(resultCodeEnum.getCode(),resultCodeEnum.getMsg());
    }

    public static Result ok(ResultCodeEnum resultCodeEnum,Object data){
        return new Result(resultCodeEnum.getCode(), resultCodeEnum.getMsg(),data);
    }

    public static Result fail(Object data){
        return new Result(ResultCodeEnum.FAIL.getCode(),ResultCodeEnum.FAIL.getMsg(),data);
    }

    public static Result fail(){
        return new Result(ResultCodeEnum.FAIL.getCode(),ResultCodeEnum.FAIL.getMsg());
    }

    public static Result fail(ResultCodeEnum resultCodeEnum){
        return new Result(resultCodeEnum.getCode(),resultCodeEnum.getMsg());
    }

    public static Result fail(ResultCodeEnum resultCodeEnum,Object data){
        return new Result(resultCodeEnum.getCode(),resultCodeEnum.getMsg(),data);
    }
}
